package org.dromara.pay.gn.job;

import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.dromara.pay.domain.PayActivityRegistration;
import org.dromara.pay.domain.bo.PayActivityRegistrationBo;
import org.dromara.pay.mapper.PayActivityRegistrationMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@JobExecutor(name = "payActivityRegistrationExecutor")
public class PayActivityRegistrationExecutor {

    @Autowired
    private PayActivityRegistrationMapper payActivityRegistrationMapper;

    public ExecuteResult jobExecute(JobArgs jobArgs) {
        List<PayActivityRegistration> payActivityRegistrationList = payActivityRegistrationMapper.selectList();
        payActivityRegistrationList.stream().forEach(payActivityRegistration -> {
            payActivityRegistration.setRegistrationStatus("1");
        });
        SnailJobLog.LOCAL.info("testJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
        SnailJobLog.REMOTE.info("testJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
        payActivityRegistrationMapper.updateBatchById(payActivityRegistrationList);
        return ExecuteResult.success("自动审核活动报名成功");
    }
}
